package com.acwing.partition4;

import java.io.*;
import java.util.ArrayDeque;
import java.util.Queue;

/**
 * @author `RKC`
 * @date 2022/1/24 18:23
 */
public class AC352闇の連鎖 {

    private static final int N = 100010, M = 200010, INF = 0x3f3f3f3f, D = (int) (Math.log(N) / Math.log(2));
    private static int[] h = new int[N], e = new int[M], ne = new int[M];
    private static int[][] f = new int[N][D + 1];
    private static int[] depth = new int[N], dist = new int[N];

    private static int n = 0, m = 0, idx = 0, ans = 0;
    private static Queue<Integer> queue = new ArrayDeque<>(N);

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] s = reader.readLine().split(" ");
        n = Integer.parseInt(s[0]);
        m = Integer.parseInt(s[1]);
        for (int i = 0; i <= n; i++) h[i] = -1;
        for (int i = 0; i < n - 1; i++) {
            s = reader.readLine().split(" ");
            int a = Integer.parseInt(s[0]), b = Integer.parseInt(s[1]);
            add(a, b);
            add(b, a);
        }
        bfs();
        for (int i = 0; i < m; i++) {
            s = reader.readLine().split(" ");
            int a = Integer.parseInt(s[0]), b = Integer.parseInt(s[1]), p = lca(a, b);
            dist[a]++;
            dist[b]++;
            dist[p] -= 2;
        }
        dfs(1, -1);
        writer.write(ans + "\n");
        writer.flush();
    }

    private static int dfs(int u, int last) {
        int res = dist[u];
        for (int i = h[u]; i != -1; i = ne[i]) {
            int v = e[i];
            if (v != last) {
                int s = dfs(v, u);
                if (s == 0) ans += m;
                else if (s == 1) ans++;
                res += s;
            }
        }
        return res;
    }

    private static int lca(int x, int y) {
        if (depth[x] < depth[y]) {
            int t = x;
            x = y;
            y = t;
        }
        for (int i = D; i >= 0; i--) {
            if (depth[f[x][i]] >= depth[y]) x = f[x][i];
        }
        if (x == y) return x;
        for (int i = D; i >= 0; i--) {
            if (f[x][i] != f[y][i]) {
                x = f[x][i];
                y = f[y][i];
            }
        }
        return f[x][0];
    }

    private static void bfs() {
        depth[1] = 1;
        queue.add(1);
        while (!queue.isEmpty()) {
            int u = queue.poll();
            for (int i = h[u]; i != -1; i = ne[i]) {
                int v = e[i];
                if (depth[v] != 0) continue;
                depth[v] = depth[u] + 1;
                f[v][0] = u;
                for (int j = 1; j <= D; j++) {
                    f[v][j] = f[f[v][j - 1]][j - 1];
                }
                queue.add(v);
            }
        }
    }

    private static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }
}
